package init;

import objects.CarBase;
import objects.CarNodeStore;

import java.util.List;

/**
 * @author whn
 * 初始化链接概率矩阵，使用链接能力矩阵和连接能力综合数组计算
 */
public class InitCarProbability {
    public static void init(CarNodeStore carNodeStore) {
        List<CarBase> list = carNodeStore.getCarList();
        double[][] ability = carNodeStore.getAbility();
        double[] abilitySumList = carNodeStore.getAbilitySumList();
        double[][] probability = carNodeStore.getProbability();
        double a,b;
        for (int i = 0; i < list.size(); i++) {
            for (int j = i; j < list.size(); j++) {
                if (j != i && ability[i][j] != 0) {
                    // TODO:书写添加规则，向概率矩阵添加内容
                    a=ability[i][j];
                    b=abilitySumList[i];
                    probability[i][j] = a / b;
                } else {
                    probability[i][j] = 0;
                }
            }
        }
        carNodeStore.setProbability(probability);
    }
}
